#include <bits/stdc++.h>

using namespace std;


int f(int n) {
    priority_queue<int, vector<int>, greater<int>> q;
    q.push(1);

    while(n--) {
        int t = q.top();
        q.pop();

        while(!q.empty() && q.top() == t) q.pop();
        q.push(t*2+1), q.push(t*3+1);
    } 
    return q.top();
}

int main() {
    int a = 100;
    cout << f(a) << endl;
}